import Vue from 'vue'
import VueRouter from 'vue-router'
import List from '../views/List'
import Home from '../views/Home'
import Reg from '../views/Reg'
import Login from '../views/Login'
import Computer from '../views/Computer'
import Mobile from '../views/Mobile'
import Goodsdetail from '../views/Goodsdetail'
import NotFound from '../views/NotFound'

Vue.use(VueRouter)

const routes = [
  {
    path: '/', // 路由重定向
    redirect: '/list'
  },
  {
    path: '/list', // 一级  首页，注册
    component: List,
    children: [
      {
        path: '/home', // 二级  电脑，手机
        component: Home,
        children: [
          {
            path: '/home/computer', // 三级  三星，苹果，联想
            component: Computer,
            children: [
              {
                path: '/goodsdetail/:id', // 电脑id 跳转
                component: Goodsdetail
              }
            ]
          },
          {
            path: '/home/mobile', // 手机号
            component: Mobile
          }
        ]
      },
      {
        path: '/reg', //  二级 QQ 和 微信注册
        component: Reg,
        children: [
          {
            path: '/reg/:name', // qq wx 跳转
            component: Login
          }
        ]
      }
    ]
  },
  {
    path: '*', // 404
    component: NotFound
  }
]

const router = new VueRouter({
  routes
})

export default router
